<template>
    <div>
        <!-- 面包屑 -->
        <el-breadcrumb separator-class="el-icon-arrow-right" style="padding-left: 10px;padding-bottom: 10px;font-size: 12px;">
            <el-breadcrumb-item :to="{ path: '/welcome' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>挂号预约</el-breadcrumb-item>
            <el-breadcrumb-item>个人信息</el-breadcrumb-item>
        </el-breadcrumb>
        <el-card style="height: 145px">
         <el-col :span="4">
           <div class="demo-image__preview">
             <el-image 
              style="width: 100px; height: 100px"
              :src="userInfo[0].avatar" 
              :preview-src-list="srcList">
             </el-image>
           </div>
         </el-col>
         <el-col :span="20">
              <el-table
               :data="userInfo"
                style="width: 100%">
                <!-- 姓名 -->
                <el-table-column
                label="姓名"
                width="120">
                <template slot-scope="scope">
                    <!-- <el-popover trigger="hover" placement="top">
                    <p>姓名: {{ scope.row.userName }}</p>
                    <p>住址: {{ scope.row.address }}</p> -->
                    <div >
                        <el-tag size="medium">{{ scope.row.userName }}</el-tag>
                    </div>
                    <!-- </el-popover> -->
                </template>
                </el-table-column>
                <!-- 性别 -->
                 <el-table-column
                label="性别"
                width="100">
                <template slot-scope="scope">
                    <!-- <i class="el-icon-time"></i> -->
                    <span style="margin-left: 1px">{{ scope.row.gender==1?'男':( scope.row.gender==0?'女':'保密') }}</span>
                </template>
                </el-table-column>
                <!-- 年龄 -->
                 <el-table-column
                label="年龄"
                width="100">
                <template slot-scope="scope">
                    <span style="margin-left: 1px">{{ scope.row.age }}</span>
                </template>
                </el-table-column>
                <!-- 手机号码 -->
                 <el-table-column
                label="联系电话"
                width="180">
                <template slot-scope="scope">
                    <span style="margin-left: 1px">{{ scope.row.phone }}</span>
                </template>
                </el-table-column>
                <!-- 密码 -->
                 <el-table-column
                label="密码"
                width="180">
                <template slot-scope="scope">
                    <span style="margin-left: 1px">{{ scope.row.password }}</span>
                </template>
                </el-table-column>
                
                
                <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button
                    size="mini"
                    type="success"
                    @click="handleEdit(scope.$index, scope.row  )" >修改</el-button>
                    <!-- <el-button
                    size="mini"
                    type="danger"
                    @click="handleDelete(scope.$index, scope.row)">删除</el-button> -->
                </template>
                </el-table-column>
            </el-table>
         </el-col>
        </el-card>
        <el-card style="margin-top: 10px; height: 350px" >
            <h1>过敏物</h1>
            <p class="content1">{{ userInfo[0].allergy}}</p>
            <el-divider></el-divider>
            <h1>既往病史</h1>
            <p class="content1">{{ userInfo[0].medicalHistory}}</p>
            
            <UpdateInformation :user="user" :addOrUpdateVisible="addOrUpdateVisible"  @changeShow="showAddOrUpdate" ref="addOrUpdateRef"></UpdateInformation>

        </el-card>


    </div>

    
</template>

<script>
import {getUserInfo} from '../../api/login'

import UpdateInformation from './UpdateInformation'

export default {
  components: { UpdateInformation },
    name: 'Information',
    data() {
      return {
        user:{},
        userInfo: [],
        srcList: [],
        addOrUpdateVisible : false,
      }
    },
    methods: {
         handleEdit(index, row) {
        this.addOrUpdateVisible = true;
        console.log(this.addOrUpdateVisible);
      },
      showAddOrUpdate(data){
      if(data === 'false'){
        this.addOrUpdateVisible = false
      }else{
        this.addOrUpdateVisible = true
      }
    },
      handleDelete(index, row) {
        console.log(index, row);
      },
       async getUserInfo() {
                console.log("加载用户信息.........");
                const res = await getUserInfo();
                console.log(res);
                //this.userInfo[0] = res.data.data.userInfo;
                this.user = res.data.data.userInfo;
                this.userInfo.push(res.data.data.userInfo);
                this.srcList.push(res.data.data.userInfo.avatar)
                console.log("userInfo为：")
                console.log(this.userInfo);
            },
    },
    mounted(){
            this.getUserInfo();
        },
  }
</script>

<style>
.content1{
    /* font-family: "KaiTi"; */
    font-weight: 400;
    /* word-spacing:10px; */
    /* 字间距 */
    letter-spacing: 1.5px;
    line-height:140%;
    font-size: 4mm;
}

</style>